home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 41 / Amiga Format CD41 (1999-06)(Future Publishing)(GB)[!][issue 1999-07].iso / -seriously_amiga- / programming / other / gtlayout / source / ltp_drawpicker.c < prev    next >
C/C++ Source or Header  |  1999-04-19  |  1KB  |  67 lines

  1. /*
  2. **    GadTools layout toolkit
  3. **
  4. **    Copyright © 1993-1998 by Olaf `Olsen' Barthel
  5. **        Freely distributable.
  6. **
  7. **    :ts=4
  8. */
  9.  
  10. #ifndef _GTLAYOUT_GLOBAL_H
  11. #include "gtlayout_global.h"
  12. #endif
  13.  
  14. #include "Assert.h"
  15.  
  16. VOID
  17. LTP_DrawPicker(struct RastPort *RPort,BOOL UpDirection,LONG Left,LONG Top,LONG Width,LONG Height)
  18. {
  19.     LONG i,Len,ArrowHeight,ArrowWidth,LineHeight,Start,Pos;
  20.  
  21.     LineHeight    = (Height + 15) / 16;
  22.     ArrowHeight    = Height - (Height + 7) / 8;
  23.     ArrowWidth    = Width;
  24.  
  25.     for(i = 0 ; i < ArrowHeight ; i++)
  26.     {
  27.         Len = ((ArrowWidth * (i + 1)) / ArrowHeight) & ~1;
  28.  
  29.         if(Len < ArrowWidth)
  30.             Len++;
  31.  
  32.         Start = Left + (ArrowWidth - Len) / 2;
  33.  
  34.         if(UpDirection)
  35.             Pos = Top + i;
  36.         else
  37.             Pos = Top + ArrowHeight - 1 - i;
  38.  
  39.         LTP_DrawLine(RPort,Start,Pos,Start + Len - 1,Pos);
  40.     }
  41.  
  42.     for(i = 0 ; i < LineHeight ; i++)
  43.         LTP_DrawLine(RPort,Left,Top + Height - 1 - i,Left + Width - 1,Top + Height - 1 - i);
  44. }
  45.  
  46. VOID
  47. LTP_DrawAdjustedPicker(
  48.     struct RastPort *    rp,
  49.     BOOL                upDirection,
  50.     LONG                left,
  51.     LONG                top,
  52.     LONG                width,
  53.     LONG                height,
  54.     LONG                aspectX,
  55.     LONG                aspectY)
  56. {
  57.     LONG Width,Height;
  58.  
  59.     Width    = 2 + (((width + 15) / 16) * aspectY) / aspectX;
  60.     Height    = 1 + ((height + 15) / 16);
  61.  
  62.     if(Width < 4)
  63.         Width = 4;
  64.  
  65.     LTP_DrawPicker(rp,FALSE,left + Width,top + Height,width - 2 * Width,height - 2 * Height);
  66. }
  67.